import 'package:flutter/material.dart';

/// 声明所有页面
final Map<String, dynamic> routes = {};

///处理路由跳转，路由传参
var onGenerateRoute = (RouteSettings settings) {
  //统一处理
  final String? name = settings.name;
  if (null == name || !routes.containsKey(name)) {
    return MaterialPageRoute(builder: (context) => const Placeholder());
  }
  final Function pageBuilder = routes[name];
  if (settings.arguments != null) {
    final Route route = MaterialPageRoute(settings: settings, builder: (context) => pageBuilder(context, arguments: settings.arguments));
    return route;
  } else {
    final Route route = MaterialPageRoute(settings: settings, builder: (context) => pageBuilder(context));
    return route;
  }
};
